const mysql = require('mysql')
const db = mysql.createPool({
    host: 'localhost',
    user: 'root',
    password: 'twitm.123',
    database: 'login'
}, () => console.log("建立连接成功"));


module.exports = (sql, arr, cb) => {
    db.query(sql, arr, function (err, res) {
        if(err) {
           return console.log(err)
        } 
        // console.log("建立连接成功");
        console.log(res);
        cb(res)
    })
}

//   connection.connect();

//   connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
//     if (error) throw error;
//     console.log('The solution is: ', results[0].solution);
//   });